package com.xiangban.yanglaodajie_platform.controller;

import com.xiangban.yanglaodajie_platform.aop.Permission;
import com.xiangban.yanglaodajie_platform.entity.Orders;
import com.xiangban.yanglaodajie_platform.entity.Shop;
import com.xiangban.yanglaodajie_platform.entity.dto.RefundDto;
import com.xiangban.yanglaodajie_platform.entity.dto.ShopDto;
import com.xiangban.yanglaodajie_platform.entity.res.ApiResult;
import com.xiangban.yanglaodajie_platform.service.OrdersService;
import com.xiangban.yanglaodajie_platform.service.ShopService;
import com.xiangban.yanglaodajie_platform.utils.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/2/20 17:13
 */
@RestController
@RequestMapping("/api/shop")
@Api(tags = "（软件）商家控制台")
public class ShopController {

    @Autowired
    private ShopService shopService;
    @Autowired
    private OrdersService ordersService;

    @PostMapping("/shopList")
    @ApiOperation("获取商家列表")
    public JsonData shopList(@RequestBody ShopDto shopDto){
       return JsonData.buildSuccess(shopService.getList(shopDto),"操作成功");
    }


    @PostMapping("/shopInfo")
    @ApiOperation("获取商家信息")
    public JsonData ShopInfo(@RequestBody Shop shop){
        return JsonData.buildSuccess(shopService.getShopInfo(shop),"操作成功");
    }

    @PostMapping("/getShopOrders")
    @ApiOperation("店铺订单(商家端)")
    @Permission(type = "shop")
    public ApiResult getShopOrders(@RequestBody Orders orders){
        return ApiResult.newSuccess(
            shopService.getShopOrders(orders)
        );
    }

    @PostMapping("/getRefundOrdersInfo")
    @ApiOperation("退款订单详情(商家端)")
    @Permission(type = "shop")
    public ApiResult RefundOrdersInfo(@RequestBody RefundDto refundDto){
        return ApiResult.newSuccess(ordersService.refundInfo(refundDto));
    }

    @PostMapping("/getOrdersClassifyNumber")
    @ApiOperation("订单类型数量(商家端)")
    @Permission(type = "shop")
    public ApiResult getOrdersClassifyNumber(@RequestBody Orders orders){
        return ApiResult.newSuccess(
            shopService.OrdersClassifyNumber(orders)
        );
    }

//    @PostMapping("/getShopOrders")
//    @ApiOperation("店铺信息(商家端)")
//    @Permission
//    public ApiResult getShopData(Object o){
//        return ApiResult.newSuccess(
//                shopService.getShopData(o)
//        );
//    }


}
